package rg.edu.ap.web.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import rg.edu.ap.po.Bath;
import rg.edu.ap.po.Merchant;
import rg.edu.ap.service.BathService;

@Controller
public class BathController {
	
	@Autowired
	private BathService bathservice;
	
	@RequestMapping("/addbath.action")
	public String addBath(Bath bath) {
		bathservice.addBath(bath);
	   return "merpage";
	}
	
	@RequestMapping("/makebath")
	public String makeBath() {
//		bathservice.addBath(bath);
	   return "makebath";
	}
	
	@RequestMapping("/addbasebath")
	public String addBaseBath(Bath bath) {
		bathservice.baseBath(bath);
	   return "merpage";
	}
	
	@RequestMapping("/setseat")
	public String getBathid(int merid,Model model,HttpSession session) {
		Bath bath = bathservice.getBathid(merid);
		model.addAttribute("bathall",bath);
		session.setAttribute("USER_SESSION_BOTH",bath);
	   return "setseat";
	}
	
	@RequestMapping("/searchbath.action")
	public String searchBath(@RequestParam(value="userprovince") String userprovince,@RequestParam(value="usercity") String usercity,@RequestParam(value="userdistrict") String userdistrict,Model model) {
		List list = bathservice.searchBath(userprovince,usercity,userdistrict);
		System.out.println(list);
		model.addAttribute("bathlist",list);
	   return "Vicinity";
	}
	
	
}
